/**
 * 判断是否已登录
 *
 */
#include "../myfastdo/myfastdo.hpp"
#include "../utils.hpp"
#include "../protocol_dist.hpp"
USING_ALL;
FASTDO_API void ActionMain(MyFastdoServer &SERV)
{
    ProtocolC2SMangaList msg;
    msg.fromMixed(SERV.data.getMixed());
    ProtocolS2CMangaList rtn;

    Mixed list = SERV.getDBH().query("select * from mangas", STATMENT_EMPTY(), DatabaseHandle::List);
    for (size_t i = 0; i < list.getCount(); i++)
    {
        Mixed &row = list[i];
        PTR_REF(pManga, manga, ProtocolObjectManga);

        manga.id = row["id"];
        manga.author = (String)row["author"];
        manga.title = (String)row["title"];
        manga.face = (String)row["face"];
        Mixed pageData;
        pageData.json(row["pages"]);
        if (pageData.isNull())
        {
            pageData.createArray();
        }
        for (size_t c = 0; c < pageData.getCount(); c++)
        {
            Mixed &pd = pageData[c];
            PTR_REF(pPage, page, ProtocolObjectMangaPage);
            page.fromMixed(pd);
            manga.pages.push_back(pPage);
        }
        rtn.manga_list.push_back(pManga);   
    }
    SERV.data.res.data = rtn.toMixed();
}